package cuit.campus.taskRunning.user.entry.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;


import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Collection;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User implements UserDetails {
    /**
     * 用户编号
     */
    @TableId(type = IdType.AUTO)
    private Integer id;
    /**
     * 用户昵称
     */
    @NotNull
    private String username;
    /**
     * 用户密码
     */
    @NotNull
    @Size(min=6,max = 10)
    private String password;
    /**
     * 用户电话号码
     */
    @Pattern(regexp = "^1[3-9]\\d{9}$")
    private String phone;
    /**
     * 用户状态 0正常 1禁用
     */
    private Integer status;
    /**
     * 用户头像
     */
    private String avatar;
    /**
     * 用户是否注销
     */
    private Integer isDelete;
    /**
     * 用户创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    /**
     * 用户更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;
    /**
     * 存权限
     */
    @TableField(exist = false)
    private List<String> pressmisses;
    /**
     * 记住我
     */
    @TableField(exist = false)
    private Integer isRemember;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
